﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.Profile;
using System.Data;
using System.Data.SqlClient;
public partial class Masterpages_Main : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
        {
            Request.Browser.Adapters.Clear();
        } 

    }
    protected void LoginView1_DataBinding(object sender, EventArgs e)
    {
       
     
    }
    protected void LoginView1_Load(object sender, EventArgs e)
    {
       
           
    }
    protected void Unnamed1_DataBinding(object sender, EventArgs e)
    {
        Label lblWelcome = (Label)LoginView1.FindControl("lblwelcome");
        Label lblnotificnum = (Label)LoginView1.FindControl("LblNotificationNumber");
        ProfileCommon p = Profile.GetProfile(Membership.GetUser().ToString());
        if(p.Common.Gender=="مرد")
        lblWelcome.Text = " آقای "+p.Common.FirstName + " " +p.Common.LastName+" " + p.HoghooghiAdvisor.Manager + lblWelcome.Text.ToString();
        else if(p.Common.Gender=="زن")
            lblWelcome.Text = " خانم " + p.Common.FirstName + " " + p.Common.LastName + " " + lblWelcome.Text.ToString();
        else
            lblWelcome.Text =  p.Common.FirstName + " " + p.Common.LastName + " " + lblWelcome.Text.ToString();
      //int num=  DataAccess.TblNotification.FetchByParameter(DataAccess.TblNotification.Columns.UserId, Membership.GetUser().ProviderUserKey).RecordsAffected;
        SubSonic.Query q1 = DataAccess.TblNotification.CreateQuery();
      q1.QueryType = SubSonic.QueryType.Select;
      q1.AddWhere(DataAccess.TblNotification.Columns.UserId, Membership.GetUser().ProviderUserKey);
      q1.AddWhere(DataAccess.TblNotification.Columns.IsRead, bool.FalseString);
     IDataReader dr= q1.ExecuteReader();
        int num=0;
        while (dr.Read())
            num += 1;
    
        lblnotificnum.Text =num.ToString();
    }
}
